﻿/// <reference path="BaseTextNode.js" />
/// <reference path="TreeNodeType.js" />

var $SelectionNode = TA.Turbo.Controls.SelectionNode = function SelectionNode()
{
	this.BaseTextNode();
}
$SelectionNode.Inherit($BaseTextNode);

var ____a;
if (____a)
{
	$SelectionNode.prototype = new $BaseTextNode();
	$SelectionNode.prototype.BaseTextNode = new $BaseTextNode();
}

$SelectionNode.prototype.Value = null;
$SelectionNode.prototype._anchor = null;


$SelectionNode.prototype.get_Type = function get_Type()
{
	return TreeNodeType.Selection;
}

$SelectionNode.prototype.SerializeContents = function SerializeContents(jw)
{
	this.BaseTextNode.SerializeContents.call(this, jw);

	if (this.Value != null)
	{
		jw.Property("V", this.Value);
	}
}
$SelectionNode.prototype.DeserializeContent = function DeserializeContent(propShortName, value)
{
	switch (propShortName)
	{
		case "V": this.Value = value; break;
		default: this.BaseTextNode.DeserializeContent.call(this, propShortName, value); break;
	}
}
$SelectionNode.prototype._CreateContent = function _CreateContent()
{
	this._anchor = document.createElement("A");
	this._anchor.AddEvent("click", this._anchor_Click, this);
	this._anchor.innerHTML = this.Text;

	this.get_DivContent().appendChild(this._anchor);
}
$SelectionNode.prototype._ParseContent = function _ParseContent()
{
	this._anchor = this.get_DivContent().FindFirstChild("A");
	this._anchor.AddEvent("click", this._anchor_Click, this);
}
$SelectionNode.prototype._anchor_Click = function _anchor_Click(e)
{
	this.get_Owner().set_Value(this.Value);
	Events.Cancel(e);
}
